
/*++

Copyright (c) 1997-2000  Microsoft Corporation All Rights Reserved

Module Name:

    minitopo.h

Abstract:

    Declaration of topology miniport.

--*/

#ifndef _MSVAD_MINTOPO_H_
#define _MSVAD_MINTOPO_H_

enum IVSHMEM_EVENTS {
    VolumeSyncFromBackend = 0,
    StatusChangeNotify,
    VolumeSyncToBackend,
};

//=============================================================================
// Classes
//=============================================================================

///////////////////////////////////////////////////////////////////////////////
// CMiniportTopology 
//   

#define MAX_WORKER_ITEM_COUNT       4

class CMiniportTopology : public IMiniportTopology, public IPowerNotify, public CUnknown {

protected:
	PADAPTERCOMMON              m_AdapterCommon;    // Adapter common object.
	PPCFILTER_DESCRIPTOR        m_FilterDescriptor; // Filter descriptor.
    BOOLEAN                     m_isIvshmemEventRegister;  // Flag to indicate ivshmem event state.
    UINT32                      m_BackendStatus;
    PWORKITEM_PARAM             m_pWorkItems;
    PEX_TIMER                   m_Timer;
    volatile UINT32             m_Volume;
    BOOLEAN                     m_isFirstVolumeSyncToBackend;

    NTSTATUS                    InitializeWorkItems(PDEVICE_OBJECT DeviceObject);
    void                        DestroyWorkItems();

public:
    DECLARE_STD_UNKNOWN();
    CMiniportTopology(PUNKNOWN outer);
    ~CMiniportTopology();

    IMP_IMiniportTopology;
    IMP_IPowerNotify;

	NTSTATUS Init(IN PUNKNOWN UnknownAdapter, IN PPORTTOPOLOGY Port_);

    // PropertyHandlers.
	NTSTATUS PropertyHandlerJackDescription(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerJackDescription2(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerBasicSupportVolume(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerCpuResources(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerGeneric(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerMute(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerMuxSource(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerVolume(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerDevSpecific(IN PPCPROPERTY_REQUEST PropertyRequest);
    NTSTATUS PropertyHandlerEvent(IN PPCEVENT_REQUEST EventRequest);
    NTSTATUS PropertyHandlerVolumeEvent(IN PPCEVENT_REQUEST EventRequest);
    VOID AddEventToEventList(IN PKSEVENT_ENTRY EventEntry);
    VOID TopologyMixerVolumeWrite(UINT32 volume);
    UINT32 GetStatusFromBackend();
    UINT32 GetSavedStatus();
    VOID SaveStatus(UINT32 status);
    PWORKITEM_PARAM GetWorkItem();
    PADAPTERCOMMON GetAdapterCommonObject();
    UINT32 GetGuestVolume();
    VOID RecordGuestVolume(UINT32 volume);

    PPORTEVENTS                 m_PortEvents;       // Event interface.
};
typedef CMiniportTopology *PCMiniportTopology;

extern NTSTATUS PropertyHandler_TopoFilter(IN PPCPROPERTY_REQUEST PropertyRequest);

#endif

